Update oXs_out_frsky.cpp
[openXsensor.git] / openXsensor / Lua scripts / FUNCTIONS / tank.lua
blob7ee3e5c2928c247668eff48d9524497e36014673
1 -- this (function) script uses as thank capacity a value stored in GVAR9 for fase 9
2 -- the value in GVAR9 is the number of 50 ml in the thank.
3 -- It means e.g. that for a thank of 1000 ml, GVAR9 must be set to 20 (=1000 / 50 )
5 local timeprev
6 local running = false
8 local function init()
10 end
12 local function run()
13 if not running then
14 running = true
15 timeprev = getTime()
16 end
17 local timenow = getTime() -- 10ms tick count
19 if timenow - timeprev > 50 then-- more than 500 msec since previous run
20 timeprev = timenow
21 local tankcapacity = 50 * model.getGlobalVariable(8, 8) -- get value of gvar 9 for flight mode 9
22 if tankcapacity < 100 then
23 tankcapacity = 100
24 end
25 if tankcapacity > 3000 then
26 tankcapacity = 3000
27 end
28 local ret = sportTelemetryPush( 0x0D , 0X10 , 8, tankcapacity )
29 end
30 end
32 return { init=init, run=run }